home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 February: Tool Chest / Apple Developer CD Series Tool Chest February 1996 (Apple Computer)(1996).iso / Sample Code / AppsToGo / Kibitz / EventLoop.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-09-22  |  2.0 KB  |  82 lines  |  [TEXT/MPS ]

  1. /*
  2. ** Apple Macintosh Developer Technical Support
  3. **
  4. ** MultiFinder-Aware Kibitz Application
  5. **
  6. ** File:             eventloop.c
  7. ** Originally from:  Traffic Light 2.0 (2.0 version by Keith Rollin)
  8. ** Modified by:      Eric Soldan
  9. **
  10. ** Copyright © 1990-1992 Apple Computer, Inc.
  11. ** All rights reserved. */
  12.  
  13.  
  14.  
  15. /*****************************************************************************/
  16.  
  17.  
  18.  
  19. #include "Kibitz.h"                /* Get the Kibitz includes/typedefs, etc.    */
  20. #include "KibitzCommon.h"        /* Get the stuff in common with rez.        */
  21. #include "Kibitz.protos"        /* Get the prototypes for Kibitz.            */
  22.  
  23. #ifndef __TEXTEDITCONTROL__
  24. #include <TextEditControl.h>
  25. #endif
  26.  
  27.  
  28.  
  29. /*****************************************************************************/
  30.  
  31.  
  32.  
  33. extern RgnHandle    gCurrentCursorRgn;        /* The current cursor region.
  34.                                             ** The initial cursor region is
  35.                                             ** an empty region, which will
  36.                                             ** cause WaitNextEvent to generate
  37.                                             ** a mouse-moved event, which will
  38.                                             ** cause us to set the cursor for
  39.                                             ** the first time.
  40.                                             */
  41. extern Boolean        gQuitApplication;        /* This is set to false by
  42.                                             ** Initialize.  When the user
  43.                                             ** selects Quit (and does not
  44.                                             ** abort the quit), then this
  45.                                             ** boolean is set true.
  46.                                             */
  47.  
  48.  
  49.  
  50. /*****************************************************************************/
  51. /*****************************************************************************/
  52.  
  53. #ifdef applec
  54. #pragma segment EventLoop
  55. #endif
  56.  
  57. /*****************************************************************************/
  58. /*****************************************************************************/
  59.  
  60.  
  61.  
  62. /* Get events forever, and handle them by calling DoEvent.  Get the events by
  63. ** calling WaitNextEvent.  (This sample does a DeathAlert if WaitNextEvent
  64. ** isn't available.) */
  65.  
  66. void    EventLoop(void)
  67. {
  68.     EventRecord        event;
  69.  
  70.     while (!gQuitApplication) {
  71.  
  72.         if (!WaitNextEvent(everyEvent, &event, 15, gCurrentCursorRgn))
  73.             event.what = nullEvent;
  74.         DoEvent(&event);
  75.  
  76.         CTEIdle();
  77.     };
  78. }
  79.  
  80.  
  81.  
  82.